import QtQuick 2.0

Item{
    width: 1080
    height: 228

    Image{
        source: "qrc:/grader/imgs/blade_bg.png"
        fillMode: Image.PreserveAspectFit
    }

    Row{
        y: 20
        anchors.horizontalCenter: parent.horizontalCenter
        spacing: 140
        Column{
            spacing: 30
            Image{
                id: leftImg
                width: 74
                height: 74
                source: "qrc:/grader/imgs/dao_left_main_2.png"
                fillMode: Image.PreserveAspectFit
            }
            Row{
                Text {
                    id:leftHeightText
                    color: "#535960"
                    text: "0"
                    font{
                        family: "Aldrich"
                        pixelSize: 64
                    }
                }
                Text {
                    id: leftUnit
                    color: "#535960"
                    text: "cm"
                    anchors.bottom: parent.bottom
                    font{
                        family: "Aldrich"
                        pixelSize: 35
                    }
                }
            }
            Connections{
                target: can_manager
                onLeft_heightChanged:{
                    if(can_manager.left_height === 0){
                        leftUnit.color = "#535960"
                        leftHeightText.color = "#535960"
                        leftImg.source = ""
                        leftImg.source = "qrc:/grader/imgs/dao_left_main_2.png"
                    }else{
                        leftUnit.color = "white"
                        leftHeightText.color = "white"
                        leftImg.source = ""
                        leftImg.source = "qrc:/grader/imgs/dao_left_main.png"
                    }

                    rightHeightText.text = String(can_manager.left_height.toFixed(0))
                }
            }
        }

        Column{
            spacing: 30
            Image{
                width: 74
                height: 74
                source: "qrc:/grader/imgs/dao_bai_main.png"
                fillMode: Image.PreserveAspectFit
            }

            Text {
                color: "white"
                text: String(can_manager.blades_slante) + "°"
                font{
                    family: "Aldrich"
                    pixelSize: 64
                }
            }
        }

        Column{
            spacing: 30
            Image{
                width: 74
                height: 74
                source: "qrc:/grader/imgs/dao_qin_main.png"
                fillMode: Image.PreserveAspectFit
            }
            Text {
                color: "white"
                text: String(can_manager.turn_circle) + "°"
                font{
                    family: "Aldrich"
                    pixelSize: 64
                }
            }
        }

        Column{
            spacing: 30
            Image{
                id: rightImg
                width: 74
                height: 74
                source: "qrc:/grader/imgs/dao_right_main_2.png"
                fillMode: Image.PreserveAspectFit
            }

            Row{
                Text {
                    id: rightHeightText
                    color: "#535960"
                    text: "0"
                    font{
                        family: "Aldrich"
                        pixelSize: 64
                    }
                }
                Text {
                    id: rightUnit
                    color: "#535960"
                    text: "cm"
                    anchors.bottom: parent.bottom
                    font{
                        family: "Aldrich"
                        pixelSize: 35
                    }
                }
            }
            Connections{
                target: can_manager
                onRight_heightChanged:{
                    if(can_manager.right_height === 0){
                        rightUnit.color = "#535960"
                        rightHeightText.color = "#535960"
                        rightImg.source = ""
                        rightImg.source = "qrc:/grader/imgs/dao_right_main_2.png"
                    }else{
                        rightUnit.color = "white"
                        rightHeightText.color = "white"
                        rightImg.source = ""
                        rightImg.source = "qrc:/grader/imgs/dao_right_main.png"
                    }

                    rightHeightText.text = String(can_manager.right_height.toFixed(0))
                }
            }
        }
    }
    function getImageSouce(source, index){
        return source.substring(0, source.lastIndexOf('.')) +"_" + String(index)+ ".png";
    }
}


